<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libcoap: coap-client(5)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">libcoap<span id="projectnumber">&#160;4.2.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('man_coap-client.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title">coap-client(5)</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>coap-client</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /></head><body><div xml:lang="en" class="refentry" lang="en"><a id="id1337"></a><div class="titlepage"></div><div class="refnamediv"><h2>NAME</h2><p>coap-client — CoAP Client based on libcoap</p></div><div class="refsynopsisdiv"><a id="_synopsis"></a><h2>SYNOPSIS</h2><p><span class="strong"><strong>coap-client</strong></span> [<span class="strong"><strong>-a</strong></span> addr] [<span class="strong"><strong>-b</strong></span> [num,]size] [<span class="strong"><strong>-e</strong></span> text] [<span class="strong"><strong>-f</strong></span> file] [<span class="strong"><strong>-l</strong></span> loss]
              [<span class="strong"><strong>-m</strong></span> method] [<span class="strong"><strong>-o</strong></span> file] [<span class="strong"><strong>-p</strong></span> port] [<span class="strong"><strong>-r</strong></span>] [<span class="strong"><strong>-s duration</strong></span>]
              [<span class="strong"><strong>-t</strong></span> type] [<span class="strong"><strong>-v</strong></span> num] [<span class="strong"><strong>-A</strong></span> type] [<span class="strong"><strong>-B</strong></span> seconds] [<span class="strong"><strong>-K</strong></span> interval]
              [<span class="strong"><strong>-N</strong></span>] [<span class="strong"><strong>-O</strong></span> num,text] [<span class="strong"><strong>-P</strong></span> addr[:port]] [<span class="strong"><strong>-T</strong></span> token] [<span class="strong"><strong>-U</strong></span>]
              [[<span class="strong"><strong>-k</strong></span> key] [<span class="strong"><strong>-u</strong></span> user]]
              [[<span class="strong"><strong>-c</strong></span> certfile] [<span class="strong"><strong>-C</strong></span> cafile] [<span class="strong"><strong>-R</strong></span> root_cafile]] URI</p></div><div class="refsect1"><a id="_description"></a><h2>DESCRIPTION</h2><p><span class="strong"><strong>coap-client</strong></span> is a CoAP client to communicate with 6LoWPAN devices via
the protocol CoAP (RFC 7252) using the URI given as argument on the
command line. The URI must have the scheme <span class="emphasis"><em>coap</em></span>, <span class="emphasis"><em>coap+tcp</em></span>, <span class="emphasis"><em>coaps</em></span> or
<span class="emphasis"><em>coaps+tcp</em></span>. <span class="emphasis"><em>coaps</em></span> and <span class="emphasis"><em>coaps+tcp</em></span> are only supported when coap-client is
built with support for secure (D)TLS communication.</p><p>If <span class="emphasis"><em>coaps</em></span> or <span class="emphasis"><em>coap+tcp</em></span> is being used, provided the CoAP server supports PKI
and is configured with a Certificate and Private Key, the coap-client does not
need to have a Pre-Shared Key (-k) or Certificate (-c) configured.</p><p>The URI’s host part may be a DNS name or a literal IP address. Note that, for
IPv6 address references, angle brackets are required (c.f. EXAMPLES).</p></div><div class="refsect1"><a id="_options_general"></a><h2>OPTIONS - General</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">
<span class="strong"><strong>-a</strong></span> addr
</span></dt><dd>
   The local address of the interface that has to be used.
</dd><dt><span class="term">
<span class="strong"><strong>-b</strong></span> [num,]size
</span></dt><dd>
   The block size to be used in GET/PUT/POST requests (value must be a
   multiple of 16 not larger than 1024 as libcoap uses a fixed maximum
   PDU size of 1400 bytes). If <span class="emphasis"><em>num</em></span> is present, the request
   chain will start at block <span class="emphasis"><em>num</em></span>. When the server includes a Block2
   option in its response to a GET request, coap-client will automatically
   retrieve the subsequent block from the server until there are no more
   outstanding blocks for the requested content.
</dd><dt><span class="term">
<span class="strong"><strong>-e</strong></span> text
</span></dt><dd>
   Include text as payload (use percent-encoding for non-ASCII characters).
</dd><dt><span class="term">
<span class="strong"><strong>-f</strong></span> file
</span></dt><dd>
   File to send with PUT/POST (use <span class="emphasis"><em>-</em></span> for STDIN).
</dd><dt><span class="term">
<span class="strong"><strong>-l</strong></span> list
</span></dt><dd>
   Fail to send some datagrams specified by a comma separated list of
   numbers or number ranges (debugging only).
</dd><dt><span class="term">
<span class="strong"><strong>-l</strong></span> loss%
</span></dt><dd>
   Randomly failed to send datagams with the specified probability - 100%
   all datagrams, 0% no datagrams (debugging only).
</dd><dt><span class="term">
<span class="strong"><strong>-m</strong></span> method
</span></dt><dd>
   The request method for action (get|put|post|delete), default is <span class="emphasis"><em>get</em></span>.
   (Note that the string passed to <span class="strong"><strong>-m</strong></span> is compared case-insensitive.)
</dd><dt><span class="term">
<span class="strong"><strong>-o</strong></span> file
</span></dt><dd>
   A filename to store data retrieved with GET.
</dd><dt><span class="term">
<span class="strong"><strong>-p</strong></span> port
</span></dt><dd>
   The port to listen on.
</dd><dt><span class="term">
<span class="strong"><strong>-r</strong></span>
</span></dt><dd>
   Use reliable protocol (TCP or TLS).
</dd><dt><span class="term">
<span class="strong"><strong>-s</strong></span> duration
</span></dt><dd>
   Subscribe to / observe the resource specified by URI for the given
   <span class="emphasis"><em>duration</em></span> in seconds.
</dd><dt><span class="term">
<span class="strong"><strong>-t</strong></span> type
</span></dt><dd><p class="simpara">
   Content format for given resource for PUT/POST. <span class="emphasis"><em>type</em></span> must be either
   a numeric value reflecting a valid CoAP content format or a string
   describing a registered format. The following registered content format
   descriptors are supported, with alternative shortcuts given in
   parentheses:
</p><pre class="literallayout">text/plain (plain)
application/link-format (link, link-format)
application/xml (xml)
application/octet-stream (binary, octet-stream)
application/exi (exi)
application/json (json)
application/cbor (cbor)</pre></dd><dt><span class="term">
<span class="strong"><strong>-v</strong></span> num
</span></dt><dd>
   The verbosity level to use (default 3, maximum is 9). Above 7, there is
   increased verbosity in GnuTLS logging.
</dd><dt><span class="term">
<span class="strong"><strong>-A</strong></span> type
</span></dt><dd>
   Accepted media type. <span class="emphasis"><em>type</em></span> must be either a numeric value reflecting a
   valid CoAP content format or a string that specifies a registered format as
   described for option <span class="strong"><strong>-t</strong></span>.
</dd><dt><span class="term">
<span class="strong"><strong>-B</strong></span> seconds
</span></dt><dd>
   Break operation after waiting given seconds (default is 90).
</dd><dt><span class="term">
<span class="strong"><strong>-K</strong></span> interval
</span></dt><dd>
   Send a ping after interval seconds of inactivity (TCP only).
   If not specified, keep-alive is disabled (default).
</dd><dt><span class="term">
<span class="strong"><strong>-N</strong></span> 
</span></dt><dd>
   Send NON-confirmable message. If option <span class="strong"><strong>-N</strong></span> is not specified, a
   confirmable message will be sent.
</dd><dt><span class="term">
<span class="strong"><strong>-O</strong></span> num,text
</span></dt><dd>
   Add option <span class="emphasis"><em>num</em></span> with contents of <span class="emphasis"><em>text</em></span> to the request.
</dd><dt><span class="term">
<span class="strong"><strong>-P</strong></span> addr[:port]
</span></dt><dd>
   Address (and port) for proxy to use (automatically adds Proxy-Uri option
   to request).
</dd><dt><span class="term">
<span class="strong"><strong>-T</strong></span> token
</span></dt><dd>
   Include the <span class="emphasis"><em>token</em></span> to the request.
</dd><dt><span class="term">
<span class="strong"><strong>-U</strong></span> 
</span></dt><dd>
   Never include Uri-Host or Uri-Port options.
</dd></dl></div></div><div class="refsect1"><a id="_options_psk"></a><h2>OPTIONS - PSK</h2><p>(If supported by underlying (D)TLS library)</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
<span class="strong"><strong>-k</strong></span> key
</span></dt><dd>
   Pre-shared key for the specified user (<span class="strong"><strong>-u</strong></span> option also required).
</dd><dt><span class="term">
<span class="strong"><strong>-u</strong></span> user
</span></dt><dd>
   User identity for pre-shared key mode (<span class="strong"><strong>-k</strong></span> option also required).
</dd></dl></div></div><div class="refsect1"><a id="_options_pki"></a><h2>OPTIONS - PKI</h2><p>(If supported by underlying (D)TLS library)</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
<span class="strong"><strong>-c</strong></span> certfile
</span></dt><dd>
   Use the specified PEM file which contains the CERTIFICATE and PRIVATE
   KEY information.
</dd><dt><span class="term">
<span class="strong"><strong>-C</strong></span> cafile
</span></dt><dd>
  PEM file containing the CA Certificate that was used to sign the certfile
  defined using <span class="strong"><strong>-c certfile</strong></span>.
  This will trigger the validation of the server certificate.
  If certfile is self-signed (as defined by <span class="strong"><strong>-c certfile</strong></span>), then you need to
  have on the command line the same filename for both the certfile and cafile
  (as in  <span class="strong"><strong>-c certfile -C certfile</strong></span>) to trigger validation.
</dd><dt><span class="term">
<span class="strong"><strong>-R</strong></span> root_cafile
</span></dt><dd>
  PEM file containing the set of trusted root CAs that are to be used to
  validate the server certificate.  The <span class="strong"><strong>-C cafile</strong></span> does not have to be in
  this list and is "trusted" for the verification.
  Alternatively, this can point to a directory containing a set of CA PEM files.
</dd></dl></div></div><div class="refsect1"><a id="_examples"></a><h2>EXAMPLES</h2><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Example
</li></ul></div><pre class="screen">coap-client coap://coap.me</pre><p>Query the resource <span class="emphasis"><em>/</em></span> from server <span class="emphasis"><em>coap.me</em></span> (using the GET method).</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Example
</li></ul></div><pre class="screen">coap-client -m get coap://[::1]/</pre><p>Query the resource <span class="emphasis"><em>/</em></span> on localhost using the <span class="emphasis"><em>GET</em></span> method to get back the
summary defined attributes.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Example
</li></ul></div><pre class="screen">coap-client -m get coap://[::1]/.well-known/core</pre><p>Query on the resource <span class="emphasis"><em>.well-known/core</em></span> on localhost to get back a list of
the known resources along with their attribute definitions.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Example
</li></ul></div><pre class="screen">echo -n "mode=on" | coap-client -m put \
coap://[2001:db8:c001:f00d:221:2eff:ff00:2704]:5683/actuators/leds?color=r -f-</pre><p>Send text <span class="emphasis"><em>mode=on</em></span> to resource <span class="emphasis"><em>actuators/leds?color=r</em></span> on the endpoint with
address <span class="emphasis"><em>2001:db8:c001:f00d:221:2eff:ff00:2704</em></span> and port <span class="emphasis"><em>5683</em></span>. Note that the
port <span class="emphasis"><em>5683</em></span> is the default port and isn’t actually required in this instance.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Example
</li></ul></div><pre class="screen">coap-client -m put coap://[fec0::3]/ck -T 3a -t binary -f to_upload</pre><p>Put the contents of file <span class="emphasis"><em>to_upload</em></span> with content type <span class="emphasis"><em>binary</em></span> (i.e.
application/octet-stream) into resource <span class="emphasis"><em>ck</em></span> on <span class="emphasis"><em>fec0::3</em></span> using a token of
<span class="emphasis"><em>3a</em></span> via the <span class="emphasis"><em>PUT</em></span> method.</p></div><div class="refsect1"><a id="_files"></a><h2>FILES</h2><p>There are no configuration files.</p></div><div class="refsect1"><a id="_exit_status"></a><h2>EXIT STATUS</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">
<span class="strong"><strong>0</strong></span>
</span></dt><dd>
   Success
</dd><dt><span class="term">
<span class="strong"><strong>1</strong></span>
</span></dt><dd>
   Failure (syntax or usage error; configuration error; document
   processing failure; unexpected error)
</dd></dl></div></div><div class="refsect1"><a id="_bugs"></a><h2>BUGS</h2><p>Please report bugs on the mailing list for libcoap:
<a class="ulink" href="mailto:libcoap-developers@lists.sourceforge.net" target="_top">libcoap-developers@lists.sourceforge.net</a></p></div><div class="refsect1"><a id="_authors"></a><h2>AUTHORS</h2><p>The libcoap project &lt;<a class="ulink" href="mailto:libcoap-developers@lists.sourceforge.net" target="_top">libcoap-developers@lists.sourceforge.net</a>&gt;</p></div></div></body></html> coap-client(5)</p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Fri Dec 27 2024 09:57:44 for libcoap by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8 </li>
  </ul>
</div>
</body>
</html>
